package zuoye2;


import java.util.Scanner;

public class Demo9 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num = (int)(Math.random()*(100+1-1)) + 1;
        System.out.println("num = " + num);//开挂
        int count = 0;
        while (true){
            System.out.print("输入你猜的数(1-100):");
            int i = input.nextInt();
            count++;
            if (num==i){
                System.out.println("猜对了，数字是："+num);
                break;
            }else if (num<i){
                System.out.println("猜大了，再猜");
            }else{
                System.out.println("猜小了，再猜");
            }

            if (count>=3){
                System.out.println("三次机会已用完 请重开");
                break;
            }
        }




    }
}
